# Required fxns: 'c2.unb','c2.rat','c2.prop','c2.pps' # Need two datasets here because of calculations # read in 'sewing machines1.csv' and 'sewing machines2.csv' # sewing machines1 has individual observations from each plant # sewing machines2 has cluster information and proportions sew1=read.csv('http://webpages.uidaho.edu/~renaes/Data/sewing%20v2.csv',header=T) sew2=read.csv('http://webpages.uidaho.edu/~renaes/Data/sewing%20v3.csv',header=T) # because of the nature of the c2.unb fxn, you will need to calculate # cluster means and variances (ybari and s2i) ybari=apply(sew1,2,mean,na.rm=T); ybari s2i=apply(sew1,2,var,na.rm=T); s2i sew2$phati # estimation of mean c2.unb('sewing',ybari,s2i,sew2$mi,sew2$Mi,4500,10,90,'mean') # estimation of total c2.unb('sewing',ybari,s2i,sew2$mi,sew2$Mi,4500,10,90,'total') # estimation of proportion c2.prop('sewing',sew2$phati,sew2$mi,sew2$Mi,10,90) # estimation of mean (ratio) c2.rat('sewing',ybari,s2i,sew2$mi,sew2$Mi,10,90,'mean') # estimation of total (ratio) c2.rat('sewing',ybari,s2i,sew2$mi,sew2$Mi,10,90,'total') # estimation of mean (pps) M=328+109+432+220+280+190 n=3; N=6; Mi=c(432,280,190) mi=c(43,28,19) yi=c(25,15,8) ybari=yi/mi # This example is a proportion but can use the formula for mean c2.pps('hospital',ybari,M,'mean')